/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

API.store = API.stores || {};

API.store.BasicStore = function(config){
    
    API.apply(this,config,{
        id: 0,
        values: []
    });
};

API.apply(API.store.BasicStore.prototype,{
    
    getID : function(){
        return ++this.id;             
    },
    
    getCurrentID : function(){
        return this.id;
    },
    
    getLength : function(){
        return this.values.length;
    },
    
    getValues : function(){
        return this.values;
    },
         
    forEachValue : function(callback){        
        API.forEachF(this.getValues(), callback);
    },
         
    getValueById : function(SearchID){

       var returnValue;
       
       API.forEachB(this.getValues(), function(value){
           if(value.id === SearchID) returnValue = value;
       });

       return returnValue;

    },
         
    addValue : function(value){
        value.id = this.getID();
        this.values.push( value );
    },
         
    remove : function(id){
        
       var  value  = this.getValueById(id),
            values = this.getValues(),
            index  = values.indexOf(value);
    
       if (index > -1) 
           values.splice(index, 1);       
       
    }
    
});